fix(code): fix branch vs default diff for unpushed changes#1874
Merged
adboio merged 1 commit intoApr 27, 2026
Merged
Conversation
This was referenced Apr 23, 2026
Contributor
Author
8baaf60 to
ec729a7
Compare
d46c6f4 to
a844b47
Compare
ec729a7 to
83a3771
Compare
a844b47 to
c9125cb
Compare
a634430 to
7d0719f
Compare
c9125cb to
1805acd
Compare
7d0719f to
cf00d9b
Compare
1805acd to
dbfc625
Compare
Contributor
Prompt To Fix All With AIThis is a comment left during a code review.
Path: packages/git/src/queries.test.ts
Line: 101-145
Comment:
**Prefer parameterised tests for `splitUnifiedDiffByFile`**
The four cases for `splitUnifiedDiffByFile` all follow the same pattern — supply a raw diff string, check keys and values in the returned map — and could be collapsed into a single `it.each` table per the team's preference for parameterised tests. The test for the two-file case is the outlier (multiple assertions), but even that can live as a row with a callback to an inline assertion helper.
```ts
it.each([
["empty input", "", []],
["binary diff", "diff --git a/image.png b/image.png\nBinary files ...", ["image.png"]],
["rename keyed by new path", "diff --git a/old.txt b/new.txt\nsimilarity index 100%\n...", ["new.txt"]],
] as const)("splitUnifiedDiffByFile: %s", (_label, raw, expectedKeys) => {
const result = splitUnifiedDiffByFile(raw);
expect([...result.keys()]).toEqual(expectedKeys);
});
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix(code): fix branch vs default diff fo..." | Re-trigger Greptile |
Comment on lines
+101
to
+145
|
|
||
| describe("splitUnifiedDiffByFile", () => { | ||
| it("returns an empty map for empty input", () => { | ||
| expect(splitUnifiedDiffByFile("")).toEqual(new Map()); | ||
| }); | ||
|
|
||
| it("splits a two-file diff keyed by post-image path", () => { | ||
| const raw = [ | ||
| "diff --git a/one.txt b/one.txt", | ||
| "index 0000000..1111111 100644", | ||
| "--- a/one.txt", | ||
| "+++ b/one.txt", | ||
| "@@ -1 +1 @@", | ||
| "-hello", | ||
| "+hello world", | ||
| "diff --git a/two.txt b/two.txt", | ||
| "new file mode 100644", | ||
| "--- /dev/null", | ||
| "+++ b/two.txt", | ||
| "@@ -0,0 +1 @@", | ||
| "+brand new", | ||
| "", | ||
| ].join("\n"); | ||
|
|
||
| const result = splitUnifiedDiffByFile(raw); | ||
|
|
||
| expect([...result.keys()]).toEqual(["one.txt", "two.txt"]); | ||
| expect(result.get("one.txt")).toContain("diff --git a/one.txt b/one.txt"); | ||
| expect(result.get("one.txt")).toContain("+hello world"); | ||
| expect(result.get("two.txt")).toContain("diff --git a/two.txt b/two.txt"); | ||
| expect(result.get("two.txt")).toContain("+brand new"); | ||
| }); | ||
|
|
||
| it("keys renames by the post-rename (b/) path", () => { | ||
| const raw = [ | ||
| "diff --git a/old.txt b/new.txt", | ||
| "similarity index 100%", | ||
| "rename from old.txt", | ||
| "rename to new.txt", | ||
| "", | ||
| ].join("\n"); | ||
|
|
||
| const result = splitUnifiedDiffByFile(raw); | ||
| expect(result.has("new.txt")).toBe(true); | ||
| expect(result.has("old.txt")).toBe(false); |
Contributor
There was a problem hiding this comment.
Prefer parameterised tests for
splitUnifiedDiffByFile
The four cases for splitUnifiedDiffByFile all follow the same pattern — supply a raw diff string, check keys and values in the returned map — and could be collapsed into a single it.each table per the team's preference for parameterised tests. The test for the two-file case is the outlier (multiple assertions), but even that can live as a row with a callback to an inline assertion helper.
it.each([
["empty input", "", []],
["binary diff", "diff --git a/image.png b/image.png\nBinary files ...", ["image.png"]],
["rename keyed by new path", "diff --git a/old.txt b/new.txt\nsimilarity index 100%\n...", ["new.txt"]],
] as const)("splitUnifiedDiffByFile: %s", (_label, raw, expectedKeys) => {
const result = splitUnifiedDiffByFile(raw);
expect([...result.keys()]).toEqual(expectedKeys);
});Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/git/src/queries.test.ts
Line: 101-145
Comment:
**Prefer parameterised tests for `splitUnifiedDiffByFile`**
The four cases for `splitUnifiedDiffByFile` all follow the same pattern — supply a raw diff string, check keys and values in the returned map — and could be collapsed into a single `it.each` table per the team's preference for parameterised tests. The test for the two-file case is the outlier (multiple assertions), but even that can live as a row with a callback to an inline assertion helper.
```ts
it.each([
["empty input", "", []],
["binary diff", "diff --git a/image.png b/image.png\nBinary files ...", ["image.png"]],
["rename keyed by new path", "diff --git a/old.txt b/new.txt\nsimilarity index 100%\n...", ["new.txt"]],
] as const)("splitUnifiedDiffByFile: %s", (_label, raw, expectedKeys) => {
const result = splitUnifiedDiffByFile(raw);
expect([...result.keys()]).toEqual(expectedKeys);
});
```
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
k11kirky
approved these changes
Apr 26, 2026
Contributor
Author
dbfc625 to
d5962b9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Problem
when a user has committed but unpushed changes, they do not show up in the "branch vs [default]" diff because we use the github APIs and compare to the remote branch
Changes
updates to use local instead of assuming remote for this case
How did you test this?
manually repro'd and tested after fix